package com.jxc.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.jxc.dao.StaffAndModuleDao;
import com.jxc.entity.Staffandmodule;

public class StaffAndModuleDaoImpl extends HibernateDaoSupport  implements StaffAndModuleDao{

	public void delete(Staffandmodule staffandmodule) {
		
		List<Staffandmodule> list=this.getHibernateTemplate().find("from Staffandmodule s where s.submodule.id=?and s.staff.id=?",
				    new Object[]{staffandmodule.getSubmodule().getId(),staffandmodule.getStaff().getId()});
		if(list.size()>0){
			
			this.getHibernateTemplate().delete(list.get(0));
		}
		
	}

	public void insert(Staffandmodule staffandmodule) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(staffandmodule);
	}

}
